package com.jeffse.light.stream.core.data.stream;

import com.jeffse.light.stream.core.data.operator.OutPutStreamOperator;
import com.jeffse.light.stream.core.function.base.SinkFunction;
import com.jeffse.light.stream.core.function.base.SourceFunction;
import com.jeffse.light.stream.core.pojo.OutTag;

import java.io.Serializable;

public interface AbstractDataStream<KEY, T, V> extends Serializable {

    public String getDataStreamName();

    /**
     * 添加数据源
     * @param sourceFunction
     * @return
     */
    public AbstractDataStream addSource(SourceFunction sourceFunction) throws Exception;

    /**
     * 添加输出
     * @param sinkFunction
     * @return
     */
    public  AbstractDataStream addSink(SinkFunction sinkFunction) throws Exception;

    /**
     * 在线程池中运行
     * @throws Exception
     */
    public  void start() throws Exception;

    /**
     * 在线程池中运行
     * @throws Exception
     */
    public  void stop() throws Exception;

    /**
     * 单流程运行
     * @throws Exception
     */
    public  void run() throws Exception;

    /**
     * 获取运行状态
     * @return
     */
    public Boolean getIsRunning();

    /**
     * 获取侧输出流
     * @param outTag
     * @return
     */
    public OutPutStreamOperator<KEY, T, V> getSideOutput(OutTag outTag);

    public void union(OutTag sourceTag, OutTag targetTag, OutTag unionTag, OutPutStreamOperator outPutStreamOperator);

}
